#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

#include <limits.h>
#include <assert.h>

#include "svm.h"
#include "utility.h"

#define FILENAME_LEN 1024
#define Malloc(type,n) (type *)malloc((n)*sizeof(type))

#ifndef SVM_TRAIN
#define SVM_TRAIN
class svmtrain
{
private:
	struct svm_parameter param;		// set by parse_command_line
	struct svm_problem prob;		// set by read_problem
	struct svm_model *model;
	struct svm_node  *x_space;
	int cross_validation;
	int nr_fold;
	double reg_param;
	double scale_param;
	char* trainDataFileName;
private:
	void read_problem(const char *filename);
	void do_cross_validation();
	double CalRBFWidth();
	void count_pattern(FILE *fp, svm_problem &prob, int &elements, int &type, int &dim);
	double labelMapping(double val, double *orgLab, double *newLab, int numMap);
	void load_pattern(FILE *fp, svm_problem &prob, int type, int dim, int bidx, int eidx, int &max_index, int &j, double *orgLab=NULL, double *newLab=NULL, int numMap=0);
public:
	void SetUpParameters(double mu, double scaleparam);
	void train(char* input_file_name, char* model_file_name);
};
#endif